package vn.edu.saigontech.ncms.web.system;

import vn.edu.saigontech.ncms.model.info.SurveyInfo;
import vn.edu.saigontech.ncms.service.SurveyInfoService;
import vn.edu.saigontech.ncms.util.Checker;
import vn.edu.saigontech.ncms.web.AbstractValidator;

@SuppressWarnings("serial")
public class ValidateSurveyInfoAction extends AbstractValidator {
	private String name;
	private String id;
	private String description;

	@Override
	public String check() {
		if(Checker.isEmpty(this.name))
			this.sendKeyError("validator.required", "name");
		SurveyInfo surveyInfo = SurveyInfoService.INSTANCE.findByName(this.name);
		if(id == null && surveyInfo != null)
			this.sendKeyError("validator.exist", this.name);
		return this.toSuccess();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
}